<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="tpl :: common_head()"></th:block>
    <th:block th:include="common/form :: editor()"></th:block>
    <title>文章管理</title>
</head>
<body th:object="${obj}" th:with="entrance='/system/post/index'">
<th:block th:replace="tpl :: common_body(~{::.main-right})">
    <div class="main-right">
        <h1 class="main-right-h1">文章管理</h1>
        <ul class="main-right-tab">
            <li><a href="index">列表</a></li>
            <li class="selected" th:if="*{id==null}">新增</li>
            <li class="selected" th:if="*{id!=null}">编辑</li>
        </ul>
        <form class="form" method="POST">
            <fieldset>
                <legend>信息</legend>
                <dl>
                    <dt>标题</dt>
                    <dd>
                        <input type="text" th:field="*{title}" data-verify="required(1)"/>
                    </dd>
                    <dt>所属栏目</dt>
                    <dd>
                        <select class="js-example-basic-single" th:field="*{channelId}">
                        <option th:each="op:*{@channelMapper.getChannelName()}" th:value="${op.id}" th:text="${op.displayName}"></option>
                        </select>
                    </dd>
                    <dt>图片</dt>
                    <dd>
                        <img id = "coverImage" onclick="showImage('coverImage','post')" style="width:200px"th:src="*{cover} != '' and *{cover} != null?*{@imageService.getImageBasePath()+cover}:'../../assets/images/add.png'" />
                        <input type="hidden" th:field="*{cover}"/>
                    </dd>
                    <dt>内容</dt>
                    <dd>
                        <div id="editor">
                        </div>
                        <input type="hidden" th:field="*{content}" />
                    </dd>
                </dl>
            </fieldset>
            <input type="submit" value="提交"/>
        </form>
    </div>
</th:block>
</body>
<script>
    var index = "";
    function close() {
        layer.close(index);
    }

    function showImage(image, type) {
        index = layer.open({
            type: 2,
            area: ['1240px', '500px'],
            title: "图片上传",
            shade: 0.6,
            scrollbar: false,
            fixed: true,
            maxmin: true,
            content: "../show/showImagePage/" + type + "/" + image
        });
    }

</script>

<style>
    .select2-drop {
        z-index: 10050 !important;
    }

    .select2-search-choice-close {
        margin-top: 0 !important;
        right: 2px !important;
        min-height: 10px;
    }

    .select2-search-choice-close:before {
        color: black !important;
    }
    /*防止select2不会自动失去焦点*/
    .select2-container {
        z-index: 16000 !important;
    }

    .select2-drop-mask {
        z-index: 15990 !important;
    }

    .select2-drop-active {
        z-index: 15995 !important;
    }
</style>
</html>